From 8be86755a9b8325684b0d5db4a539c50713bdf27 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 28 Dec 2005 15:17:04 +0100 Subject: [PATCH] Fix a leak occurring at netif_map(). The problem raised after allocating both {rx,tx}_comms_area, and one (and just one) of them failed. As we were doing a single test for both, returning would leave one of them allocated. Signed-off-by: Glauber de Oliveira Costa --- linux-2.6-xen-sparse/drivers/xen/netback/interface.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c index c2641d99c9..16cc929a11 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c @@ -196,9 +196,13 @@ int netif_map(netif_t *netif, unsigned long tx_ring_ref, return 0; netif->tx_comms_area = alloc_vm_area(PAGE_SIZE); + if (netif->tx_comms_area == NULL) + return -ENOMEM; netif->rx_comms_area = alloc_vm_area(PAGE_SIZE); - if (netif->tx_comms_area == NULL || netif->rx_comms_area == NULL) + if (netif->rx_comms_area == NULL) { + free_vm_area(netif->tx_comms_area); return -ENOMEM; + } err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref); if (err) { -- 2.30.2